import request from '../../util/request'

export default  {

  /**
   *  更新SKU的价格
   * @param skuId
   * @param price
   * @private
   */
  __api__ProductSkuPriceUpdate:(skuId, price)=>{
    return request({
      url:'/products/sku/price',
      method:'patch',
      data:{skuId:skuId,price:price}
    })
  },

  /**
   *  更新SKU的库存
   * @param skuId
   * @param count
   * @private
   */
  __api__ProductSkuCountUpdate:(skuId, count)=>{
    return request({
      url:'/products/sku/count',
      method:'patch',
      data:{skuId:skuId,count:count}
    })
  },

  /**
   *  更新SKU名称
   * @param skuId
   * @param name
   * @private
   */
  __api__ProductSkuNameUpdate:(skuId, name)=>{
    return request({
      url:'/products/sku/name',
      method:'patch',
      data:{skuId:skuId,name:name}
    })
  },

  /**
   *  添加SKU
   * @param params
   * @private
   */
  __api__ProductSkuAdd:(params)=>{
    return request({
      url:'/products/sku',
      method:'post',
      data:params
    })
  },

  /**
   *  更新SKU详情
   * @param params
   * @private
   */
  __api__ProductSkuDetailsUpdate(params){
    return request({
      url:'/products/sku',
      method:'put',
      data: params
    })
  },

  /**
   *  获取SKU详情
   * @param id
   * @private
   */
  __api__ProductSkuDetails:(id)=>{
    return request({
      url:'/products/sku/'+id,
      method:'get'
    })
  },

  /**
   *  删除多个SKU
   * @param params
   * @private
   */
  __api__ProductSkusDelete:(params)=>{
    return request({
      url:'/products/sku',
      method:'delete',
      data:params
    })
  },

  /**
   *  删除一个SKU
   * @param id
   * @private
   */
  __api__ProductSkuDelete:(id)=>{
    return request({
      url:'/products/sku',
      method:'delete',
      data:[id]
    })
  },

  /**
   *  删除一个SPU
   * @param id
   * @private
   */
  __api__ProductSpuDelete:(id)=>{
    return request({
      url:'/products',
      method:'delete',
      data:[id]
    })
  },

  /**
   *  删除多个SPU
   * @param params
   * @private
   */
  __api__ProductSpusDelete:(params)=>{
    return request({
      url:'/products',
      method:'delete',
      data:params
    })
  },

  /**
   *  启用/禁用多个SPU
   * @param spuIds
   * @param banSale
   * @private
   */
  __api__ProductSpusBanSaleUpdate:(spuIds, banSale)=>{
    return request({
      url:'/products/spu/banSale',
      method:'put',
      data:{banSale:banSale,spuIds:spuIds}
    })
  },

  /**
   *  启用/禁用一个SPU
   * @param spuId
   * @param banSale
   * @private
   */
  __api__ProductSpuBanSaleUpdate:(spuId, banSale)=>{
    return request({
      url:'/products/spu/banSale',
      method:'put',
      data:{banSale:banSale,spuIds:[spuId]}
    })
  },

  /**
   *  添加SPU
   * @param params
   * @private
   */
  __api__ProductSpuAdd:(params)=>{
    return request({
      url:'/products/spu',
      method:'post',
      data:params
    })
  },

  /**
   *  通过code查询SPU
   * @param spuCode
   * @private
   */
  __api__ProductSpuGetByCode:(spuCode)=>{
    return request({
      url:'/products/'+spuCode,
      method:'get'
    })
  },

  /**
   *   获取可显示的分类数据
   * @private
   */
  __api__CategoriesOnlyShow:()=>{
    return request({
      url:'/categories/show',
      method:'get'
    })
  },

  /**
   *  获取所有分类数据
   * @private
   */
  __api__Categories:()=>{
    return request({
      url:'/categories',
      method:'get'
    })
  },

  /**
   *   获取一个SPU的所有SKU数据
   * @param spuId
   * @private
   */
  __api__ProductSpuSkus:(spuId)=>{
    return request({
      url:'/products/skus/'+spuId,
      method:'get'
    })
  },

  /**
   *  分页查询SPU
   * @param params
   * @private
   */
  __api__ProductSpusPage:(params)=>{
    return request({
      url:'/products/spus',
      method:'get',
      params:params
    })
  },

  /**
   *  获取SPU图片
   * @param spuId
   * @private
   */
  __api__ProductSpuImages:(spuId)=>{
    return request({
      url:'/products/spu/'+spuId+'/images',
      method:'get'
    })
  },

  /**
   *  添加SPU的图片
   * @param params
   * @private
   */
  __api__ProductSpuImageAdd:(params)=>{
    return request({
      url:'/products/spu/image',
      method:'post',
      data:params
    })
  },

  /**
   *  删除SPU图片
   * @param imageId
   * @private
   */
  __api__ProductSpuImageDelete:(imageId)=>{
    return request({
      url:'/products/spu/image/'+imageId,
      method:'delete'
    })
  },

  /**
   *  删除SKU图片
   * @param imageId
   * @private
   */
  __api__ProductSkuImageDelete:(imageId)=>{
    return request({
      url:'/products/sku/image/'+imageId,
      method:'delete'
    })
  }

}
